
#ifndef __ENCRYPT_WRAPPER_H
#define __ENCRYPT_WRAPPER_H

#include <vector>
#include "EncryptionKey.h"
#include "SigningKey.h"
#include "../aprtools/APRBucketBrigade.h"

#ifndef ENV_READ_BUFFER
#define ENV_READ_BUFFER 65536
#endif

/** Wrapper for generating and managing encryption processes. */
class EncryptWrapper
{
   public:
      EncryptWrapper(EncryptionKey *enckey);
      EncryptWrapper(EncryptionKey *enckey, SigningKey *sgnkey);
      EncryptWrapper(EncryptionKey *enckey, int compress);
      EncryptWrapper(EncryptionKey *enckey, SigningKey *sgnkey, int compress);
      ~EncryptWrapper();
      char *encryptDataBuffer(const char *buffer, apr_size_t length, apr_size_t *newlength);
      APRBucketBrigade *encryptToBucket(APRBucketBrigade *bbrgde);
   private:
      /** Copy constructor for the class. */
      EncryptWrapper(const EncryptWrapper &o);
      /** Copy assignment operator for the class. */
      EncryptWrapper &operator=(const EncryptWrapper &o);
      void initEncryptWrapper(EncryptionKey *enckey, SigningKey *sgnkey, int compress);
      /** Key to be used for encryption. */
      EncryptionKey *enckeycopy;
      /** Key to be used for signing data. */
      SigningKey *sgnkeycopy;
      /** A flag holding whether to add a compression envelope to the
       * process. */
      int docompress;
      /** A flag to say whether to add signatures to the data. */
      int trusted;
      /** The APR memory pool for creating bucket brigades. */
      apr_pool_t *mp;
};

#endif
